<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>秀视频后台管理平台-专栏模块</title>
<meta name="keywords" content="秀视频后台管理平台是基于HTML5+css3编写的页面" />
<meta name="description" content="秀视频后台管理平台欢迎您的到来" />
<link rel="shortcut icon" href="favicon.ico" />
<link th:href="@{/static/css/github-gist.css}" rel="stylesheet" />
<link th:href="@{/static//css/bootstrap.min.css}" rel="stylesheet" />
<link th:href="@{/static//css/font-awesome.css}" rel="stylesheet" />
<link
	th:href="@{/static//css/plugins/bootstrap-table/bootstrap-table.min.css}"
	rel="stylesheet" />
<link th:href="@{/static//css/animate.css}" rel="stylesheet" />
<link th:href="@{/static//css/style.css}" rel="stylesheet" />
<link th:href="@{/static//css/index.css}" rel="stylesheet" />
<link th:href="@{/static//css/base.css}" rel="stylesheet" />
<link th:href="@{/static//css/fakeLoader.css}" rel="stylesheet" />
<link th:href="@{/static//css/plugins/sweetalert/sweetalert.css}"
	rel="stylesheet" />
<style>
.news_infos span {
	font-size: 13px;
}

#picker {
	display: none;
}
</style>
</head>

<body class="white-bg" style="opacity: 0">
	<div class="row">
		<div class="col-sm-12">
			<div class="ibox float-e-margins">
				<div class="ibox-content">
					<form class="form-horizontal" name="sub_form"
						enctype="multipart/form-data">
						<input id="id" type="hidden" name="id" th:value="${category.id}" /> <input
							type="hidden" name="status" th:value="1" />
						<div class="form-group">
							<label class="col-sm-2 control-label">标题</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" id="title" name="title"
									th:value="${category?.name}" /> <span
									class="help-block m-b-none"></span>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label">内容</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" id="description" name="description"
									th:value="${category?.content}" /> <span
									class="help-block m-b-none">描述</span>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label">图片</label>
							<div class="col-sm-10">
								<img id="img" th:src="${category?.imageUrl}"
									style="width: 200xp; height: 200px" /> <input onchange="uploadFile()" id="file" type="file"
									name="file" />
							</div>
						</div>
						<div class="form-group">
							<div class="col-sm-4 col-sm-offset-2">
								<button class="btn btn-primary" type="button" onclick="updateSubmit()">保存修改</button>
								<button class="btn btn-white" onclick="back()">返回</button>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
function uploadFile()
{
	$("#filename").html(file.name);
	var fileName = $("#file").val();
    var fileObj = document.getElementsByName("file")[0].files[0];
    var reader = new FileReader();
    reader.readAsDataURL(fileObj);
    reader.onload = function (ev) {
        $("#img").attr("src", ev.target.result);
    }
    if (fileName == '' || fileName == undefined) {
        swal("文件名称不能为空", "请重新操作", "error");
        $("#file").empty();
        return;
    }
    if (fileObj.size >= 10240000)  //10M以上的图片无法上传
    {
        swal("图片大小超出限制", "请重新操作", "error");
        return;
    }
    var jpg = (fileName.indexOf(".jpg") > -1) || (fileName.toLowerCase().indexOf(".jpg") > -1);
    var png = (fileName.indexOf(".png") > -1) || (fileName.toLowerCase().indexOf(".png") > -1);
    var jpeg = (fileName.indexOf(".jpeg") > -1) || (fileName.toLowerCase().indexOf(".jpeg") > -1);
    //判断文件是否是图片类型
    if (jpg || png || jpeg) {

    } else {
        swal("请选择图片类型的图片", "请重新操作", "error");
        $("#file").empty();
        return;
    }
	
	
}
</script>
<script type="text/javascript">
	function back() {
		window.location.href = document.referrer;
	}
	function updateSubmit() {
		       var form = new FormData();
		       var id=$("#id").val();
		       var name=$("#title").val();
		       var description=$("#description").val();
		       var fileObj = document.getElementsByName("file")[0].files[0];     
		       form.append("name",name);
		       form.append("description",description);
		       form.append("file",fileObj);   
		       form.append("id",id);
		       form.append("status","1");     
		          　$.ajax({
		               url:"../../category/updateCategory",
		               type:"post",
		               data:form,
		               processData:false,
		               contentType:false,
		               success:function(data){
		               swal("提交成功","","success");
		     
		                $('#modal-form').modal('hide');
						$("#allBlog").bootstrapTable('refresh');

		               }
		     });

	}
</script>


<script th:src="@{/static/js/jquery-2.1.1.min.js}"></script>


<script th:src="@{/static/js/jquery.min.js}"></script>
<script th:src="@{/static/js/highlight.pack.js}"></script>
<script>
	hljs.initHighlightingOnLoad();
</script>
<script th:src="@{/static/js/bootstrap.min.js}"></script>
<!-- 自定义js -->
<script th:src="@{/static/js/plugins/sweetalert/sweetalert.min.js}"></script>
<script th:src="@{/static/js/contabs.js}"></script>
<script th:src="@{/static/js/fakeLoader.min.js}"></script>

<!-- Bootstrap table -->
<script
	th:src="@{/static/js/plugins/bootstrap-table/bootstrap-table.min.js}"></script>
<script
	th:src="@{/static/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js}"></script>
<script
	th:src="@{/static/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js}"></script>
<script th:src="@{/static/js/colum/column.js}"></script>
<script>
	function loadFile(file) {
		$("#filename").html(file.name);
	}
</script>
</html>
